import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class main2 {
    private static int[] M = new int[20];
    private static int[] D = new int[20];

    public static void main(String[] args) {
        int[] month = {3, 6, 9, 12};
        int[] day = {4, 5, 8, 7, 1, 2};
        int[][] riqi = new int[4][4];
        for (int i = 0; i < month.length; i++) {
            riqi[i][0] = month[i];
        }
        riqi[0][1] = day[0];
        riqi[0][2] = day[1];
        riqi[0][3] = day[2];
        riqi[1][1] = day[0];
        riqi[1][2] = day[3];
        riqi[2][1] = day[4];
        riqi[2][2] = day[1];
        riqi[3][1] = day[4];
        riqi[3][2] = day[5];
        riqi[3][3] = day[2];
        ArrayList<Integer> 筛选的月 = new ArrayList<Integer>();
        筛选的月 = 找月(riqi);
        ArrayList<Integer> 筛选的日 = new ArrayList<Integer>();
        筛选的日 = 找日(筛选的月, riqi);
        筛选的月 = 再找月(筛选的日,筛选的月,riqi);
        for (int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(筛选的月.contains(riqi[i][0])&&筛选的日.contains(riqi[i][j])){
                    System.out.println(riqi[i][0]+"."+riqi[i][j]);
                }
            }
        }
    }

    private static ArrayList<Integer> 找月(int[][] riqi) {
        int t = 0;
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j < 4; j++) {
                D[t++] = riqi[i][j];
            }
        }
        ArrayList<Integer> day_only = 寻找唯一(D);
        t = 0;
        for (int i = 0; i < day_only.size(); i++) {
            for (int k = 0; k < 4; k++) {
                for (int j = 1; j < 4; j++) {
                    if (riqi[k][j] == 0) {
                        continue;
                    } else if (day_only.get(i) == riqi[k][j]) {
                        M[t++] = riqi[k][0];
                    }
                }
            }
        }
        ArrayList<Integer> res = new ArrayList<Integer>();
        for (int i = 0; i < M.length; i++) {
            if (M[i] != 0) {
                res.add(M[i]);
            }
        }
        return res;
    }

    private static ArrayList<Integer> 再找月(ArrayList<Integer> 筛选的日, ArrayList<Integer> 筛选的月, int[][] riqi) {
        int t=0;
        int[] mouth = new int[20];
        for (int k = 0; k < 4; k++) {
            for (int j = 1; j < 4; j++) {
                if (riqi[k][j] == 0) {
                    continue;
                } else if (!筛选的月.contains(riqi[k][0])&&筛选的日.contains((riqi[k][j]))) {
                    mouth[t++] = riqi[k][0];
                }
            }
        }

        ArrayList<Integer> month_only = new ArrayList<Integer>();
        month_only = 寻找唯一(mouth);
        return month_only;
    }

    private static ArrayList<Integer> 找日(ArrayList<Integer> 筛选的月, int[][] riqi) {
        int t = 0;
        int[] day = new int[20];

        for (int k = 0; k < 4; k++) {
            for (int j = 1; j < 4; j++) {
                if (riqi[k][j] == 0) {
                    continue;
                } else if (!筛选的月.contains(riqi[k][0])) {
                    day[t++] = riqi[k][j];
                }
            }
        }


        ArrayList<Integer> day_only = new ArrayList<Integer>();
        day_only = 寻找唯一(day);
        return day_only;
    }

    public static ArrayList<Integer> 寻找唯一(int[] array) {
        ArrayList<Integer> res = new ArrayList<Integer>();
        if (array == null || array.length < 2)
            return res;
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < array.length; i++) {
            if (map.containsKey(array[i])) {
                map.put(array[i], map.get(array[i]) + 1);
            } else {
                map.put(array[i], 1);
            }
        }
        for (Integer key : map.keySet()) {
            if (map.get(key) == 1)
                res.add(key);
        }
        return res;
    }
}
